id/email
password
forgot password | create account
about | help | prefs
ReadingBatcode reading practice

 

 

Warmup 1JoinEnds

prev  |  next  |  chance

This is a description of JoinEnds

public static String joinEnds(String str) {
    if (str.length() < 2)
        return str;

    String b = str.substring(0, 1);
    String e = str.substring(str.length() - 1);

    return e + b;
}
Function Call  Return Value
joinEnds("Blue zebra")
joinEnds("Tree")
joinEnds("Truck")
joinEnds("P")
joinEnds("ab")
joinEnds("")

Experiment with this code on Gitpod.io

Work on a similar problem on CodingBat.com

⬅ Back